package cn.tedu._06interceptor.base.config;

import cn.tedu._06interceptor.base.interceptors.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    //addI + 回车
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
//        registry.addInterceptor(new MyInterceptor())
//                .addPathPatterns("/v1/**");
//        registry.addInterceptor(new MyInterceptor())
//                .addPathPatterns("/v1/user/login","/v1/user/reg");
//        registry.addInterceptor(new MyInterceptor())
//                .addPathPatterns("/v1/user/**");
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/v1/user/**")
                .excludePathPatterns("/v1/user/login");
    }
}
